package cn.wolfcode.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;

@Getter
@Setter
public class Courseorder {
    private Long id;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date inputTime;

    private Customer customer;

    private Classinfo classinfo;

    private Long money;

    public String getJson(){
        HashMap<Object,Object> map = new HashMap<>();
        map.put("id",id);
        if (customer!=null){

            map.put("cusId",customer.getId());
        }
        if (classinfo!=null){

            map.put("clsId",classinfo.getId());
        }
        map.put("money",money);

        return JSON.toJSONString(map);//不能传this,否则死循环
    }

}